package com.wd.shared;

import java.io.File;

/**
 * @author jerome
 * @version 1.0, 2009-9-7
 */
public class Constants {

	private static String MAINHOME = null;	
	public static String SEPARATOR = File.separator;
	public static final String MAIN_CONFIG = getMainHome() + SEPARATOR + "conf";


    public static final String CONFIG_DBPOOL_PROPERTIES = MAIN_CONFIG + SEPARATOR + "dbpool" + SEPARATOR + "dbpool.properties";
    
    public static final String CONFIG_LOG4J_PROPERTIES = MAIN_CONFIG + SEPARATOR + "log4j" + SEPARATOR + "log4j.properties";
    public static final String CONFIG_GENERAL_PROPERTIES = MAIN_CONFIG + SEPARATOR + "conf.properties";
    
    public static final String CONFIG_CURR_PROPERTIES = getMainHome() + SEPARATOR;
    
    public static final int INTERVAL_LOG4J_WATCH = 10*60*1000;
    
    
    public static final String COMMA_SPLIT = ","; 
//    public static final String COLON_SPLIT = ":";
    public static final String DOUBLE_ERECT_SPLIT = "\\|\\|";
    public static final String SINGLE_ERECT_SPLIT = "\\|";
//    public static final String DB_WRITER_SPLIT = "|";
//    public static final String FILE_READER_SPLIT = "\\|\\|";
//    public static final String FILE_WRITER_SPLIT = "||";
    

    
    //task execute state
    public static final int TASK_EXECUTE_STATE_SUCCESS = 0;
    public static final int TASK_EXECUTE_STATE_FAIL = 1;
    
    //os temp file dir
    public static final String SYSTEM_TEMP_DIR = "java.io.tmpdir"; 
    
    
    
    public static synchronized String getMainHome(){
    	if (MAINHOME == null) {
    		MAINHOME = System.getProperty("user.dir");
//    		log.info("MIANHOME : " + MAINHOME);    		
    	}    	
    	if (MAINHOME.startsWith("/workspace")) {
    		return MAINHOME;
    	}
    	if (isUnix()) {
    		MAINHOME = MAINHOME.substring(0, MAINHOME.lastIndexOf(SEPARATOR));
    	}
    	return MAINHOME;
    }
    
    public static boolean isUnix(){
    	if (System.getProperty("os.name").equalsIgnoreCase("Unix")
    			|| System.getProperty("os.name").equalsIgnoreCase("Lunix")){
    		return true;
    	} else {
    		return false;
    	}	
    }
    

    
    public static void main(String args[]) {
//    	System.out.println(getMainHome());
    	System.out.println(CONFIG_LOG4J_PROPERTIES);
    }
}

